package com.resource.manager.search.vo;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

/**
 * 文件类型区分
 */
@Data
@Accessors(chain = true)
public class FileType implements Serializable {

    public static final List<String> IMAGE_SUFFIX = Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg","ico", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw","arw", "WMF", "webp", "avif", "apng");


    private String id;

    /**
     * 图标
     */
    private String ico;

    /**
     * 后缀
     */
    private List<String> suffix = new ArrayList<>();

    /**
     * 类型名称
     */
    private String name;

    /**
     * 排序
     */
    private Integer sort;

    private int x;
    private int y;
    private int width = 100;
    private int height = 120;


    public static List<FileType> buildDefaultFileType(){
        List<FileType> types = new ArrayList<>();
        List<String> imgSuffix = Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg","ico", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw","arw", "WMF", "webp", "avif", "apng");
        types.add(new FileType().setName("图片").setIco("img/image.png").setSort(1).setSuffix(imgSuffix));
        types.add(new FileType().setName("Word文档").setIco("img/word.png").setSort(2).setSuffix(Arrays.asList("doc", "docx")));
        types.add(new FileType().setName("Excel文档").setIco("img/excel.png").setSort(3).setSuffix(Arrays.asList("xls", "xlsx")));
        types.add(new FileType().setName("PPT文档").setIco("img/ppt.png").setSort(4).setSuffix(Arrays.asList("ppt", "pptx")));
        types.add(new FileType().setName("PDF文档").setIco("img/pdf.png").setSort(5).setSuffix(Arrays.asList("pdf")));
        types.add(new FileType().setName("TXT文档").setIco("img/text.png").setSort(6).setSuffix(Arrays.asList("txt", "md","text","properties","yml","yaml","xml","json","log","html")));
        types.add(new FileType().setName("音频").setIco("img/mp3.png").setSort(7).setSuffix(Arrays.asList("mp3", "wav", "wma", "ogg", "aac")));
        types.add(new FileType().setName("视频").setIco("img/mp4.png").setSort(8).setSuffix(Arrays.asList("mp4", "avi", "rmvb", "mkv", "wmv", "mov")));
        types.add(new FileType().setName("压缩文件").setIco("img/zip.png").setSort(9).setSuffix(Arrays.asList("zip", "rar", "7z", "tar", "gz", "jar", "iso")));
        types.add(new FileType().setName("应用").setIco("img/exe.png").setSort(10).setSuffix(Arrays.asList("exe", "msi", "bat", "sh", "cmd", "vbs", "ps")));
        types.forEach(t->{
            t.setId(UUID.randomUUID().toString());
        });
        return types;
    }

    public static List<FileType> buildImageFileType(){
        List<FileType> types = new ArrayList<>();
        List<String> imgSuffix = Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg","ico", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw","arw", "WMF", "webp", "avif", "apng");
        types.add(new FileType().setName("图片").setIco("img/image.png").setSort(1).setSuffix(imgSuffix));
        types.forEach(t->{
            t.setId(UUID.randomUUID().toString());
        });
        return types;
    }

}
